#include <stdio.h>

// error version

int main ()
{

    int n = 0 , low = 0 , high = 0 , number = 0 ;

    scanf("%d" , &n) ;

    int array [10001] = { 0 } ;

    for (int i = 0 ; i < n ; i++)
    {

        scanf("%d" , &array [i]) ;

    }


    for (int i = 2 ; i < n ; i++)
    {

        if (array [i] < array [i - 1])
        {

            if (array [low] < array [high])
            {

                number++ ;

                low = i ;

                high = 0 ;

                continue ;

            }

            low = i ;

        }

        if (array [i] > array [i - 1])
        {

            high = i ;

        }

    }

    printf("%d" , number) ;

    return 0 ;

}